package com.wu.common.utils;


import java.io.*;

public class FileUtils {
    public FileUtils() {
    }

    public static void readToBuffer(StringBuffer buffer, String filePath) throws IOException {
        InputStream is = new FileInputStream(filePath);
        BufferedReader reader = new BufferedReader(new InputStreamReader(is));

        for(String line = reader.readLine(); line != null; line = reader.readLine()) {
            buffer.append(line);
            buffer.append("\n");
        }

        reader.close();
        is.close();
    }

    public static String readFile(String filePath) throws IOException {
        StringBuffer sb = new StringBuffer();
        readToBuffer(sb, filePath);
        return sb.toString();
    }
}
